****************************************************************************
* This dofile is written to accompany the paper:
* A Leigh, "Who Benefits from the Earned Income Tax Credit? Incidence Among Recipients, Coworkers and Firms", 
* BE Journal of Economic Analysis & Policy (2009)
* Feel free to use or adapt the dofile, so long as you cite that paper.
* Questions to andrew_leigh@ksg02.harvard.edu.
*
* Please note that this is a pretty complex dofile, which took over a year to write. 
* The details are contained in the paper and appendices, but do not expect to be able to figure out all the 
* details in a few hours (indeed, just running it may take several hours, depending on 
* your computing power).
****************************************************************************

set more off 
version 10.0
clear
program drop _all
cd "K:\EITC\"
set mem 100m
set matsize 800
set more off

program define morgcleanup

label define _state 11 ME 12 NH 13 VT 14 MA 15 RI 16 CT 21 NY 22 NJ 23 PA 31 OH 32 IN 33 IL 34 MI 35 WI 41 MN 42 IA 43 MO 44 ND 45 SD 46 NE 47 KS 51 DE 52 MD 53 DC 54 VA 55 WV 56 NC 57 SC 58 GA 59 FL 61 KY 62 TN 63 AL 64 MS 71 AR 72 LA 73 OK 74 TX 81 MT 82 ID 83 WY 84 CO 85 NM 86 AZ 87 UT 88 NV 91 WA 92 OR 93 CA 94 AK 95 HI
label values state _state
decode state, gen(stcode)
label drop _all

* For 1994-99, we can only get children aged 16+. This is a flawed solution, so we only use "ownchild" for 1993-1999
if year<=1993 | year>=2000 | (year==1999 & intmonth>=11) {
gen children=ownchild if pfamrel==1 | pfamrel==2 | pfamrel==5
replace children=0 if pfamrel~=1 & pfamrel~=2 & pfamrel~=5
gen childmiss=0
}
else {
gen children=.
gen childmiss=1
}

recode children 3/max=3
label var children "Respondent's # of own children"

if year<=1993 {
gen selfemp=1 if class==5 | class==6
}
if year>=1994 {
gen selfemp=1 if class94==6 | class94==7
}
recode selfemp .=0
label var selfemp "Self employed"

gen year4=year
label var year4 "Four digit year"

replace race=3 if race>2 & race~=.

* The following lines generate education variables from the schooling variables in the CPS
* Note that beginning in 1991, the CPS categorizes educational attainment differently
* than in previous years.  This program attempts to make variables consistent across
* years. Note that there is another problem pre-1988, but NBER MORG already solves it.

if year<=1991 {
* Years of schooling
gen edu=gradeat
* Subtract one year if the highest grade attended is not completed (gradecp==2)
replace edu=edu-1 if gradecp==2 & edu>=1
}
if year>=1992 {
gen edu=grade92
recode edu 31=0 32=2.5 33=5.5 34=7.5 35=9 36=10 37=11 38=11.5 39=12 40=13 41=14 42=14 43=16 44=18 45=18 46=20
}
label variable edu "Highest grade completed"

gen date=(year*100)+intmonth
gen cpi=.
for num 101.9 102.4 102.6 103.1 103.4 103.7 104.1 104.5 105 105.3 105.3 105.3 105.5 106 106.4 106.9 107.3 107.6 107.8 108 108.3 108.7 109 109.3 109.6 109.3 108.8 108.6 108.9 109.5 109.5 109.7 110.2 110.3 110.4 110.5 111.2 111.6 112.1 112.7 113.1 113.5 113.8 114.4 115 115.3 115.4 115.4 \ num 198401 198402 198403 198404 198405 198406 198407 198408 198409 198410 198411 198412 198501 198502 198503 198504 198505 198506 198507 198508 198509 198510 198511 198512 198601 198602 198603 198604 198605 198606 198607 198608 198609 198610 198611 198612 198701 198702 198703 198704 198705 198706 198707 198708 198709 198710 198711 198712: replace cpi=X if date==Y
for num 115.7 116 116.5 117.1 117.5 118 118.5 119 119.8 120.2 120.3 120.5 121.1 121.6 122.3 123.1 123.8 124.1 124.4 124.6 125 125.6 125.9 126.1 127.4 128 128.7 128.9 129.2 129.9 130.4 131.6 132.7 133.5 133.8 133.8 134.6 134.8 135 135.2 135.6 136 136.2 136.6 137.2 137.4 137.8 137.9 \ num 198801 198802 198803 198804 198805 198806 198807 198808 198809 198810 198811 198812 198901 198902 198903 198904 198905 198906 198907 198908 198909 198910 198911 198912 199001 199002 199003 199004 199005 199006 199007 199008 199009 199010 199011 199012 199101 199102 199103 199104 199105 199106 199107 199108 199109 199110 199111 199112: replace cpi=X if date==Y
for num 138.1 138.6 139.3 139.5 139.7 140.2 140.5 140.9 141.3 141.8 142 141.9 142.6 143.1 143.6 144 144.2 144.4 144.4 144.8 145.1 145.7 145.8 145.8 146.2 146.7 147.2 147.4 147.5 148 148.4 149 149.4 149.5 149.7 149.7 150.3 150.9 151.4 151.9 152.2 152.5 152.5 152.9 153.2 153.7 153.6 153.5 154.4 154.9 155.7 156.3 156.6 156.7 157 157.3 157.8 158.3 158.6 158.6 \ num 199201 199202 199203 199204 199205 199206 199207 199208 199209 199210 199211 199212 199301 199302 199303 199304 199305 199306 199307 199308 199309 199310 199311 199312 199401 199402 199403 199404 199405 199406 199407 199408 199409 199410 199411 199412 199501 199502 199503 199504 199505 199506 199507 199508 199509 199510 199511 199512 199601 199602 199603 199604 199605 199606 199607 199608 199609 199610 199611 199612: replace cpi=X if date==Y
for num 159.1 159.6 160 160.2 160.1 160.3 160.5 160.8 161.2 161.6 161.5 161.3 161.6 161.9 162.2 162.5 162.8 163 163.2 163.4 163.6 164 164 163.9 164.3 164.5 165 166.2 166.2 166.2 166.7 167.1 167.9 168.2 168.3 168.3 \ num 199701 199702 199703 199704 199705 199706 199707 199708 199709 199710 199711 199712 199801 199802 199803 199804 199805 199806 199807 199808 199809 199810 199811 199812 199901 199902 199903 199904 199905 199906 199907 199908 199909 199910 199911 199912: replace cpi=X if date==Y
for num 168.8 169.8 171.2 171.3 171.5 172.4 172.8 172.8 173.7 174 174.1 174 175.1 175.8 176.2 176.9 177.7 178 177.5 177.5 178.3 177.7 177.4 176.7 177.1 177.8 178.8 179.8 179.8 179.9 180.1 180.7 181 181.3 181.3 180.9 181.7 183.1 184.2 \ num 200001 200002 200003 200004 200005 200006 200007 200008 200009 200010 200011 200012 200101 200102 200103 200104 200105 200106 200107 200108 200109 200110 200111 200112 200201 200202 200203 200204 200205 200206 200207 200208 200209 200210 200211 200212 200301 200302 200303: replace cpi=X if date==Y
for num 183.8 183.5 183.7 183.9 184.6 185.2 185.0 184.5 184.3 185.2 186.2 187.4 188.0 189.1 189.7 189.4 189.5 189.9 190.9 191.0 190.3 190.7 191.8 193.3 194.6 194.4 194.5 195.4 196.4 198.8 199.2 197.6 196.8 \ num 200304 200305 200306 200307 200308 200309 200310 200311 200312 200401 200402 200403 200404 200405 200406 200407 200408 200409 200410 200411 200412 200501 200502 200503 200504 200505 200506 200507 200508 200509 200510 200511 200512: replace cpi=X if date==Y 
replace cpi=cpi/195.3
label var cpi "CPI-U (2005=1)"
drop date

gen wage=earnwke/uhourse
gen lwage=ln((earnwke/uhourse)/cpi)
label var lwage "Real log hourly wage ($2005)"

gen male=sex
recode male 1=1 2=0
gen black=race
recode black 2=1 1=0 3/max=0
gen hispanic=1 if ethnic<=6
recode hispanic .=0
gen othrace=1 if race~=1 & black==0 & hispanic==0
recode othrace .=0
gen ed_hsdropout=1 if edu<12
recode ed_hsdropout .=0
gen ed_hsgrad=1 if edu==12
recode ed_hsgrad .=0
gen ed_somecoll=1 if edu>12 & edu<16
recode ed_somecoll .=0
gen ed_college=1 if edu>=16
recode ed_college .=0
gen black_male=black*male
gen hispanic_male=hispanic*male
gen othrace_male=othrace*male
gen agesq=age^2
ren earnwt wgt

if year<=1988 {
gen employed=1 if esr==1 | esr==2
}
if year>=1989 & year<=1993 {
gen employed=1 if lfsr89==1 | lfsr89==2 | lfsr89==5
}
if year>=1994 {
gen employed=1 if lfsr94==1 | lfsr94==2
}
recode employed .=0
label var employed "Employed last week"
label var agesq "Age squared"
label var ed_hsdropout "High school dropout"
label var ed_hsgrad "High school only"
label var ed_somecoll "Some college"
label var ed_college "BA or above"
label var male "Male"
label var black "Black"
label var hispanic "Hispanic"
label var othrace "Other non-white"
label var black_male "Black male"
label var hispanic_male "Hispanic male"
label var othrace_male "Other NW male"

keep age agesq edu ed_* male black* hispanic* othrace* marital pfamrel wgt cpi* paidhre earnhre earnwke selfemp child* ethnic* minsamp state hhid hhnum lineno year* stcode wage lwage intmonth* uhourse* employed ind80 occ80

compress
sort year
end

*************************************************
* Combining MORG files for 1984-2002
*************************************************
for any 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00 01 02 : use "K:\MORG\morgX", clear \ morgcleanup \ sort year \ save "K:\EITC\morgcleanX", replace

set more off
clear
cd K:\EITC\
* Combining the merges into a single file"
set mem 900m
use morgclean84.dta, clear
for any 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00 01 02 : merge year using morgcleanX \ drop _merge \ sort year
compress
tab year
gen str20 temp=hhid
destring temp, replace force
ren hhid hhid_s
la var hhid_s "HHID (string)"
ren temp hhid 
la var hhid "HHID (byte)"
compress
note: TS - Merged MORG files 1984-2002
save morgA, replace

********************************************************************************
* Creating a subset of faminc and children data from the March CPS 
********************************************************************************

*Creating a single file of "own children" and "faminc" from the March CPS

cd K:\MarchCPS\
for any 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00 01 02: use marX.dta, clear \ keep _year _child18 _child6 _faminc _hhid hhid state lineno mis _incwag \ keep if mis==4 | mis==8 \ ren _faminc faminc \ ren _incwag incwag \ ren _year year \ destring year, force replace \ destring hhid, generate (hhid_b) force \ sort year \ save kidsX.dta, replace
clear
for any 84: use kidsX.dta, clear
for any 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00 01 02: merge year using kidsX.dta \ drop _merge \ sort year
tab year 
sort hhid lineno state year
save kids_temp1.dta, replace
use kids_temp1, clear
replace year=year-1
drop faminc
drop if year<1994 | year>1999
sort hhid lineno state year
save kids_temp2, replace
use kids_temp1, clear
replace year=year+1
drop faminc
drop if year<1994 | year>1999
sort hhid lineno state year
save kids_temp3, replace
use kids_temp1, clear
for num 2/3: merge hhid lineno state year using kids_tempX \ tab _merge \ drop _merge \ sort hhid lineno state year 
for num 1/3: erase kids_tempX.dta
cd K:\EITC\
save kids_all, replace

********************************************************************************
* Merging the "kids" and "faminc" file with the MORG file - MARCH DATA ONLY
******************************************************************************** 
clear
set mem 1200m
set more off
cd K:\EITC\
use morgA, clear
ren hhid hhid_b
ren hhid_s hhid
sort hhid lineno state year
merge hhid lineno state year using kids_all, nokeep
bysort year: tab _merge
bysort year: tab _merge if intmonth==3

gen child_march=.
la var child_march "Children (merged from March CPS)"
replace child_march=_child18 if (pfamrel==1 | pfamrel==2 | pfamrel==5) & _merge==3
replace child_march=0 if pfamrel~=1 & pfamrel~=2 & pfamrel~=5 & _merge==3
replace children=child_march if childmiss==1
recode children 3/max=3
recode child_march 3/max=3

drop _merge _child6 _child18 lineno hhid_b mis year4 minsamp paidhre earnhre

for any age agesq ed_hsdropout ed_hsgrad ed_somecoll ed_college male black hispanic othrace black_male hispanic_male othrace_male incwag: gen temp1=X if pfamrel==1 \ bysort hhid: egen temp2=max(X) \ gen s_X=temp2 if pfamrel==2 \ gen temp3=X if pfamrel==2 \ bysort hhid: egen temp4=max(X) \ replace s_X=temp4 if pfamrel==1 \ drop temp* 

compress

* We briefly code missing children as 9, so these observations can have a one-child state-year EITC rate merged on.
recode children .=9
sort stcode year children
merge stcode year children using "State EITC rates.dta", nokeep
recode children 9=.
tab _merge
drop _merge
for var eitc_s_c* eitc_rate_s*: recode X .=0

for any 1 2 3: gen childX=1 if children==X \ recode childX .=0 if children~=.
label var child1 "One child"
label var child2 "Two children"
label var child3 "Three children"

bysort year: tab children if lwage~=.

sort stcode year 
merge stcode year using "Stateunemploymentrates.dta", nokeep
tab _merge
drop _merge

sort state year 
merge state year using "Stateincometax.dta", nokeep
tab _merge
drop _merge

* This makes the EITC rate and the unemployment rate into a 0/1 variable, not a 0/100 variable.
*for any eitc_rate_t eitc_rate_t2 eitc_rate_t3 eitc_rate_a eitc_rate_a2 eitc_rate_a3 eitc_rate_f eitc_s_child0 eitc_s_child1 eitc_s_child2 eitc_s_child3 eitc_rate_s u: replace X=X/100
for any eitc_s_child0 eitc_s_child1 eitc_s_child2 eitc_s_child3 eitc_rate_s eitc_rate_s2 eitc_rate_s3 u: replace X=X/100

compress
note: TS - MORG dataset with unemployment and EITC but not minimum wages
save morgB, replace
for num 1: use morgB, clear \ sample X \ save morgB_Xpct, replace

clear
set mem 1000m
use morgB if age>=25 & age<=55, clear

gen cpiy=.
for X in num 1984/2002 \ Y in num 0.578 0.598 0.609 0.631 0.658 0.689 0.727 0.757 0.780 0.803 0.824 0.847 0.872 0.892 0.906 0.926 0.957 0.984 1.000: replace cpiy=Y if year==X

* ASSIGNING MINIMUM WAGES

gen stfips=.
for @ in any AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY \ # in num 02 01 05 04 06 08 09 11 10 12 13 15 19 16 17 18 20 21 22 25 24 23 26 27 29 28 30 37 38 31 33 34 35 32 36 39 40 41 42 44 45 46 47 48 49 51 50 53 55 54 56: replace stfips=# if stcode=="@"

gen date=year*10000+(intmonth)*100+(01)

* Written 4-04-03, amended 4-11-03. This program assigns a minimum wage to an individual in a given state at all times since 1984
*Contact Raj Chetty (chetty@post.harvard.edu) or Jesse Shapiro (jmshapir@post.harvard.edu) with questions
*Coded from MLR January issues on the web by David Lee, Harvard University
*Inputs: date (yyyymmdd form) and state (FIPS codes)
*Output: minwage (minimum wage that applies to the individual)



* 1984-87 is coded up by Andrew Leigh (andrew_leigh@ksg02.harvard.edu), using tables from Council of State Governments, "The Book of the States 1988-89", Table 8.27, pp.381-382. Note that while 1987-2003 is coded by precise date, any changes in the 1984-87 period are coded as occurring on 1 January of the following year (no more detail is presented in the table).
* The Book of the States contradicted David Lee's coding in seven respects. According to the Book of the States: DC has a min wage range of $3.50-3.90 (av $3.70) from 1985-87; IO had no general min wage pre-1990; MA had a min wage of $3.55 on 1/1/1987; MO's min wage only started in 1991. ND had a min wage of $2.80-3.10 (av $2.95) from 1984-91; UT had a min wage of $2.50-2.75 (av $2.62) from 1984-90; VA had a min wage of $2.65 from 1984-91. Each of these 7 edits is made below.

*FEDERAL MINIMUM WAGE
gen fed_min=3.35 if date>=19810101
replace fed_min=3.80 if date>=19900401& date<19910401
replace fed_min=4.25 if date>=19910401& date<19961001
replace fed_min=4.75 if date>=19961001& date<19970901 
replace fed_min=5.15 if date>=19970901

*STATE MINIMUM WAGE
*No state law in: 1,4,12,22,28,45,47 (this is also true from 1984-87)

gen state_min = .

replace state_min=3.85 if stfips==2 & date>=19840101
replace state_min=4.30 if stfips==2 & date>=19900401
replace state_min=4.75 if stfips==2 & date>=19910401
replace state_min=5.25 if stfips==2 & date>=19961001
replace state_min=5.65 if stfips==2 & date>=19970901
replace state_min=7.15 if stfips==2 & date>=20030101

replace state_min=3.05 if stfips==5 & date>=19840101 
replace state_min=3.15 if stfips==5 & date>=19850101 
replace state_min=3.25 if stfips==5 & date>=19880101
replace state_min=3.30 if stfips==5 & date>=19890101
replace state_min=3.35 if stfips==5 & date>=19890901
replace state_min=3.65 if stfips==5 & date>=19910701
replace state_min=4.00 if stfips==5 & date>=19920701
replace state_min=4.15 if stfips==5 & date>=19930801
replace state_min=4.25 if stfips==5 & date>=19940701
replace state_min=4.75 if stfips==5 & date>=19970701

replace state_min=3.35 if stfips==6 & date>=19840101
replace state_min=3.30 if stfips==6 & date>=19890101
replace state_min=4.25 if stfips==6 & date>=19960101
replace state_min=4.75 if stfips==6 & date>=19961001
replace state_min=5.00 if stfips==6 & date>=19970301
replace state_min=5.15 if stfips==6 & date>=19980101
replace state_min=5.75 if stfips==6 & date>=19980301
replace state_min=6.25 if stfips==6 & date>=20010101
replace state_min=6.75 if stfips==6 & date>=20020101

replace state_min=2.50 if stfips==8 & date>=19840101
replace state_min=3.00 if stfips==8 & date>=19850101
replace state_min=4.75 if stfips==8 & date>=19961101
replace state_min=5.15 if stfips==8 & date>=19971001

replace state_min=3.37 if stfips==9 & date>=19840101
replace state_min=3.75 if stfips==9 & date>=19871001
replace state_min=4.25 if stfips==9 & date>=19881001
replace state_min=4.27 if stfips==9 & date>=19910401
replace state_min=4.77 if stfips==9 & date>=19970101
replace state_min=5.18 if stfips==9 & date>=19970901
replace state_min=5.65 if stfips==9 & date>=19990101
replace state_min=5.65 if stfips==9 & date>=20000101
replace state_min=6.15 if stfips==9 & date>=20010101
replace state_min=6.70 if stfips==9 & date>=20020101

replace state_min=3.00 if stfips==10 & date>=19840101
replace state_min=3.35 if stfips==10 & date>=19870520
replace state_min=3.80 if stfips==10 & date>=19900401
replace state_min=4.25 if stfips==10 & date>=19910401
replace state_min=4.65 if stfips==10 & date>=19960415
replace state_min=5.00 if stfips==10 & date>=19970101
replace state_min=5.15 if stfips==10 & date>=19970901

replace state_min=5.65 if stfips==10 & date>=19990501
replace state_min=6.15 if stfips==10 & date>=20001001

replace state_min=3.70 if stfips==11 & date>=19840101
replace state_min=3.90 if stfips==11 & date>=19870101
replace state_min=4.85 if stfips==11 & date>=19871218
replace state_min=3.80 if stfips==11 & date>=19880101
replace state_min=4.75 if stfips==11 & date>=19881010
replace state_min=3.50 if stfips==11 & date>=19900101
replace state_min=4.50 if stfips==11 & date>=19900401
replace state_min=3.70 if stfips==11 & date>=19910101
replace state_min=5.45 if stfips==11 & date>=19910210
replace state_min=5.25 if stfips==11 & date>=19960101
replace state_min=5.75 if stfips==11 & date>=19961001

replace state_min=1.25 if stfips==13 & date>=19840101
replace state_min=3.25 if stfips==13 & date>=19850101
replace state_min=5.15 if stfips==13 & date>=20010701

replace state_min=3.35 if stfips==15 & date>=19840101
replace state_min=3.85 if stfips==15 & date>=19880101
replace state_min=4.75 if stfips==15 & date>=19910401
replace state_min=3.85 if stfips==15 & date>=19920101
replace state_min=4.75 if stfips==15 & date>=19920401
replace state_min=5.25 if stfips==15 & date>=19930101
replace state_min=5.75 if stfips==15 & date>=20020101

replace state_min=2.30 if stfips==16 & date>=19840101
replace state_min=3.80 if stfips==16 & date>=19900401
replace state_min=3.80 if stfips==16 & date>=19910101
replace state_min=4.25 if stfips==16 & date>=19910401
replace state_min=4.75 if stfips==16 & date>=19970401

replace state_min=2.65 if stfips==17 & date>=19840101
replace state_min=3.00 if stfips==17 & date>=19850101
replace state_min=3.35 if stfips==17 & date>=19860101
replace state_min=3.80 if stfips==17 & date>=19900401
replace state_min=4.25 if stfips==17 & date>=19910401
replace state_min=4.75 if stfips==17 & date>=19961001
replace state_min=5.15 if stfips==17 & date>=19970901

replace state_min=2.00 if stfips==18 & date>=19840101
replace state_min=3.35 if stfips==18 & date>=19900701
replace state_min=4.25 if stfips==18 & date>=19981001
replace state_min=5.15 if stfips==18 & date>=19990301

replace state_min=3.85 if stfips==19 & date>=19900101
replace state_min=3.85 if stfips==19 & date>=19900101
replace state_min=4.25 if stfips==19 & date>=19910101
replace state_min=4.65 if stfips==19 & date>=19920101
replace state_min=4.75 if stfips==19 & date>=19961001
replace state_min=5.15 if stfips==19 & date>=19970901

replace state_min=1.60 if stfips==20 & date>=19840101
replace state_min=3.65 if stfips==20 & date>=19880701

replace state_min=2.60 if stfips==21 & date>=19840101
replace state_min=3.35 if stfips==21 & date>=19870101
replace state_min=3.80 if stfips==21 & date>=19900715
replace state_min=4.25 if stfips==21 & date>=19910715
replace state_min=5.15 if stfips==21 & date>=19980715

replace state_min=3.35 if stfips==23 & date>=19840101
replace state_min=3.45 if stfips==23 & date>=19850101
replace state_min=3.55 if stfips==23 & date>=19860101
replace state_min=3.65 if stfips==23 & date>=19870101
replace state_min=3.75 if stfips==23 & date>=19890101
replace state_min=3.85 if stfips==23 & date>=19900101
replace state_min=4.25 if stfips==23 & date>=19910401
replace state_min=4.75 if stfips==23 & date>=19961001

replace state_min=5.15 if stfips==23 & date>=19970901
replace state_min=5.75 if stfips==23 & date>=20020101


replace state_min=3.35 if stfips==24 & date>=19840101
replace state_min=3.80 if stfips==24 & date>=19900401
replace state_min=4.25 if stfips==24 & date>=19910401
replace state_min=4.75 if stfips==24 & date>=19961001
replace state_min=5.15 if stfips==24 & date>=19970901

replace state_min=3.35 if stfips==25 & date>=19840101
replace state_min=3.55 if stfips==25 & date>=19870101
replace state_min=3.65 if stfips==25 & date>=19880101
replace state_min=3.75 if stfips==25 & date>=19880701
replace state_min=4.25 if stfips==25 & date>=19950101
replace state_min=4.75 if stfips==25 & date>=19960101
replace state_min=5.25 if stfips==25 & date>=19970101
replace state_min=6.00 if stfips==25 & date>=20000101
replace state_min=6.75 if stfips==25 & date>=20010101

replace state_min=3.35 if stfips==26 & date>=19840101
replace state_min=4.75 if stfips==26 & date>=19970501

replace state_min=3.35 if stfips==27 & date>=19840101
replace state_min=3.85 if stfips==27 & date>=19890101
replace state_min=4.25 if stfips==27 & date>=19970101
replace state_min=5.15 if stfips==27 & date>=19970901

replace state_min=3.80 if stfips==29 & date>=19910101
replace state_min=4.25 if stfips==29 & date>=19910401
replace state_min=4.75 if stfips==29 & date>=19961001
replace state_min=5.15 if stfips==29 & date>=19970901

replace state_min=2.75 if stfips==30 & date>=19840101
replace state_min=3.05 if stfips==30 & date>=19860101
replace state_min=3.35 if stfips==30 & date>=19870101
replace state_min=3.80 if stfips==30 & date>=19900401
replace state_min=4.25 if stfips==30 & date>=19960101
replace state_min=4.75 if stfips==30 & date>=19961001
replace state_min=5.15 if stfips==30 & date>=19970901

replace state_min=1.60 if stfips==31 & date>=19840101
replace state_min=3.35 if stfips==31 & date>=19870829
replace state_min=4.25 if stfips==31 & date>=19910701
replace state_min=5.15 if stfips==31 & date>=19970901

replace state_min=2.75 if stfips==32 & date>=19840101
replace state_min=3.35 if stfips==32 & date>=19870910
replace state_min=3.80 if stfips==32 & date>=19900401
replace state_min=4.25 if stfips==32 & date>=19910401
replace state_min=4.75 if stfips==32 & date>=19961001
replace state_min=5.15 if stfips==32 & date>=19970901

replace state_min=3.35 if stfips==33 & date>=19840101
replace state_min=3.45 if stfips==33 & date>=19870101
replace state_min=3.55 if stfips==33 & date>=19880101
replace state_min=3.65 if stfips==33 & date>=19890101
replace state_min=3.75 if stfips==33 & date>=19900101
replace state_min=3.85 if stfips==33 & date>=19910101
replace state_min=4.25 if stfips==33 & date>=19910401
replace state_min=4.75 if stfips==33 & date>=19961001
replace state_min=5.15 if stfips==33 & date>=19970901

replace state_min=3.35 if stfips==34 & date>=19840101
replace state_min=3.80 if stfips==34 & date>=19900503
replace state_min=4.25 if stfips==34 & date>=19910401
replace state_min=5.05 if stfips==34 & date>=19920401
replace state_min=5.15 if stfips==34 & date>=19990121

replace state_min=3.35 if stfips==35 & date>=19840101
replace state_min=4.25 if stfips==35 & date>=19930701

replace state_min=3.35 if stfips==36 & date>=19840101
replace state_min=3.80 if stfips==36 & date>=19900401
replace state_min=4.25 if stfips==36 & date>=19910401


replace state_min=5.15 if stfips==36 & date>=20000331
replace state_min=4.25 if stfips==36 & date>=20000101
replace state_min=5.15 if stfips==36 & date>=20010301

replace state_min=3.35 if stfips==37 & date>=19840101
replace state_min=3.80 if stfips==37 & date>=19920101
replace state_min=4.25 if stfips==37 & date>=19930101
replace state_min=4.75 if stfips==37 & date>=19970801

replace state_min=2.95 if stfips==38 & date>=19840101
replace state_min=3.40 if stfips==38 & date>=19910101
replace state_min=4.25 if stfips==38 & date>=19910801
replace state_min=4.75 if stfips==38 & date>=19961001
replace state_min=5.15 if stfips==38 & date>=19970901

replace state_min=2.30 if stfips==39 & date>=19840101
replace state_min=3.80 if stfips==39 & date>=19900924
replace state_min=4.25 if stfips==39 & date>=19910401

replace state_min=3.35 if stfips==40 & date>=19840101
replace state_min=3.80 if stfips==40 & date>=19900401
replace state_min=4.25 if stfips==40 & date>=19910401
replace state_min=4.75 if stfips==40 & date>=19961001
replace state_min=5.15 if stfips==40 & date>=19970901

replace state_min=3.10 if stfips==41 & date>=19840101
replace state_min=3.35 if stfips==41 & date>=19860101
replace state_min=3.85 if stfips==41 & date>=19900901
replace state_min=4.25 if stfips==41 & date>=19900101
replace state_min=4.75 if stfips==41 & date>=19910101
replace state_min=5.50 if stfips==41 & date>=19970101

replace state_min=6.00 if stfips==41 & date>=19980101
replace state_min=6.50 if stfips==41 & date>=19990101

replace state_min=3.35 if stfips==42 & date>=19840101
replace state_min=3.70 if stfips==42 & date>=19880201
replace state_min=3.35 if stfips==42 & date>=19890101
replace state_min=3.70 if stfips==42 & date>=19890201
replace state_min=3.35 if stfips==42 & date>=19900101
replace state_min=3.80 if stfips==42 & date>=19900401
replace state_min=4.25 if stfips==42 & date>=19910401
replace state_min=4.75 if stfips==42 & date>=19961001
replace state_min=5.15 if stfips==42 & date>=19970901

replace state_min=3.35 if stfips==44 & date>=19840101
replace state_min=3.55 if stfips==44 & date>=19870101
replace state_min=3.65 if stfips==44 & date>=19870701
replace state_min=4.00 if stfips==44 & date>=19880701
replace state_min=4.25 if stfips==44 & date>=19890801
replace state_min=4.45 if stfips==44 & date>=19910401
replace state_min=4.75 if stfips==44 & date>=19960901
replace state_min=5.15 if stfips==44 & date>=19970101
replace state_min=5.65 if stfips==44 & date>=19990701
replace state_min=6.15 if stfips==44 & date>=20000901

replace state_min=2.80 if stfips==46 & date>=19840101
replace state_min=3.35 if stfips==46 & date>=19880701
replace state_min=3.80 if stfips==46 & date>=19900401
replace state_min=4.25 if stfips==46 & date>=19910401
replace state_min=4.75 if stfips==46 & date>=19970401

replace state_min=1.40 if stfips==48 & date>=19840101
replace state_min=3.35 if stfips==48 & date>=19870901
replace state_min=5.15 if stfips==48 & date>=20010901

replace state_min=2.62 if stfips==49 & date>=19840101
replace state_min=3.80 if stfips==49 & date>=19900401
replace state_min=4.25 if stfips==49 & date>=19910401
replace state_min=4.75 if stfips==49 & date>=19961001
replace state_min=5.15 if stfips==49 & date>=19970901

replace state_min=3.35 if stfips==50 & date>=19840101
replace state_min=3.45 if stfips==50 & date>=19870101
replace state_min=3.55 if stfips==50 & date>=19870701
replace state_min=3.65 if stfips==50 & date>=19880702
replace state_min=3.75 if stfips==50 & date>=19890702
replace state_min=3.85 if stfips==50 & date>=19900401
replace state_min=4.25 if stfips==50 & date>=19910401
replace state_min=4.50 if stfips==50 & date>=19950102
replace state_min=4.75 if stfips==50 & date>=19960102
replace state_min=5.00 if stfips==50 & date>=19970102
replace state_min=5.15 if stfips==50 & date>=19970701
replace state_min=5.25 if stfips==50 & date>=19990101
replace state_min=5.75 if stfips==50 & date>=19991001
replace state_min=6.26 if stfips==50 & date>=20010101



replace state_min=2.65 if stfips==51 & date>=19840101
replace state_min=3.65 if stfips==51 & date>=19910701
replace state_min=4.25 if stfips==51 & date>=19920701
replace state_min=5.15 if stfips==51 & date>=19970901

replace state_min=2.30 if stfips==53 & date>=19840101
replace state_min=3.85 if stfips==53 & date>=19890101
replace state_min=4.25 if stfips==53 & date>=19900101
replace state_min=4.90 if stfips==53 & date>=19940101
replace state_min=5.70 if stfips==53 & date>=19990101
replace state_min=6.72 if stfips==53 & date>=20010101

replace state_min=3.05 if stfips==54 & date>=19840101
replace state_min=3.35 if stfips==54 & date>=19870101
replace state_min=3.80 if stfips==54 & date>=19910401
replace state_min=4.25 if stfips==54 & date>=19920401

replace state_min=4.75 if stfips==54 & date>=19971001
replace state_min=5.15 if stfips==54 & date>=19980901

replace state_min=3.25 if stfips==55 & date>=19840101
replace state_min=3.35 if stfips==55 & date>=19870901
replace state_min=3.65 if stfips==55 & date>=19880101
replace state_min=3.35 if stfips==55 & date>=19890101
replace state_min=3.65 if stfips==55 & date>=19890701
replace state_min=3.80 if stfips==55 & date>=19900401
replace state_min=4.25 if stfips==55 & date>=19920301
replace state_min=4.75 if stfips==55 & date>=19961001
replace state_min=5.15 if stfips==55 & date>=19970901

replace state_min=1.60 if stfips==56 & date>=19840101

replace state_min=5.15 if stfips==56 & date>=20010401

*Final assigment: binding minimum wage is max of federal and state
gen rminwage = ln((max(state_min,fed_min))/cpiy)
label var rminwage "Log real minimum wage"

* Recoding lwage as missing in the case of excessively high or low wages 
replace lwage=. if wage<(fed_min/2)
replace lwage=. if wage>(fed_min*100)
drop state_min fed_min date wage

sort stfips year
merge stfips year using "state personal income per capita - yearly.dta", nokeep
drop _merge
sort stfips year
merge stfips year using "AFDC rates 1984-2002", nokeep
drop _merge
replace maxbenefit=ln(maxbenefit/cpiy)
la var maxbenefit "Log real maximum AFDC/TANF benefit for a family of 3"
replace welfarereform=0 if year<1989
replace afdcwaiver=0 if year<1989
sort stfips year
merge stfips year using gsp_pop.dta, nokeep
gen gsp_cap=ln(((1000000*gsp)/cpiy)/pop)
la var gsp_cap "Log real GSP per capita"
drop gsp pop _merge

gen adult=1 if age>=25 & age<=55 & selfemp~=1 & lwage~=. & employed==1 & uhourse~=.
recode adult .=0
gen singlewomen=1 if age>=25 & age<=55 & marital>3 & male==0 & selfemp~=1 & lwage~=. & employed==1 & uhourse~=.
recode singlewomen .=0
label var adult "Aged 25-55, positive hours, positive earnings, employed, not selfemp"
label var singlewomen "Single women aged 25-55, positive hours, positive earnings, employed, not selfemp, HS dropout"
gen child0=1 if children==0
replace child0=0 if children>0 & children~=.
gen female=1 if male==0
recode female .=0

gen stateyear=(year*100)+state
la var stateyear "State*Year"

recode ind80 12=20 20=21 30=20 31=30 32=31 450=460 451=461 452=462 623=630 630=631 631=632 632=640 633=640 661=682 662=661 663=662 732=740 740=741 741=742 742=750 801=800 802=801 810=802 863=862 873=881 891=730 892=732 893=892 if year>=1992
recode occ80 16=17 17=19 18=16 19=18 21=19 22=19 349=353 461=463 462=464 463=465 464=466 465=467 466=468 467=468 628=633 864=863 865=864 866=865 867=866 868=867 874=873 if year>=1992

gen ind_occ80=(ind80*1000)+occ80
la var ind_occ80 "Unique industry-occupation cell number (1980 codes)"

gen occ90=occ80
gen ind90=ind80
recode occ90 17=16 16=18 18=19 19=22 349=353 369=368 437=436 463=461 464=462 465=463 466=464 467=465 633=628 673=674 794=795 805=804 863=864 864=865 865=866 866=867 867=868 873=874 905=. -9=. 999=.
recode ind90 21=20 20=30 30=31 31=32 382=. 460=450 461=451 462=452 522=. 630=623 631=630 632=631 640=633 661=662 662=663 730=891 740=732 741=740 742=741 801=802 802=810 732=892 892=893 991=. -9=. 999=.
gen ind_occ90=(ind90*1000)+occ90
la var ind_occ90 " Unique industry-occupation cell number (1990 codes)"

**********************************************************
* Giving everyone their precise EITC rate - note that this is endogenous to earnings
**********************************************************

gen eitc_exact_a=.
* Phase-in range
for Y in num 1984/2002 \ A in num 0 0 0 0 0 0 0 0 0 0 7.65 7.65 7.65  7.65  7.65  7.65 7.65 7.65 7.65 \ B in num 5000 5000 5000 6080 6240 6500 6810 0 0 0 4000 4100 4220 4340 4460 4530 4610 4760 4910: replace eitc_exact_a=A/100 if year==Y & children==0 & faminc<=B
for Y in num 1984/2002 \ A in num 10 14 14 14 14 14 14 16.7 17.6 18.5 23.6 34 34 34 34 34 34 34 34 \ B in num 5000 5000 5000 6080 6240 6500 6810 7140 7520 7750 7750 6160 6330 6500 6680 6800 6920 7140 7370: replace eitc_exact_a=A/100 if year==Y & children==1 & faminc<=B 
for Y in num 1984/2002 \ A in num 10 14 14 14 14 14 14 17.3 18.4 19.5 30 36 40 40 40 40 40 40 40 \ B in num 5000 5000 5000 6080 6240 6500 6810 7140 7520 7750 8425 8640 8890 9140 9390 9540 9720 10020 10350: replace eitc_exact_a=A/100 if year==Y & children>1 & children~=. & faminc<=B 

* Flat range
for Y in num 1984/2002 \ B in num 5000 5000 5000 6080 6240 6500 6810 0 0 0 4000 4100 4220 4340 4460 4530 4610 4760 4910 \ C in num 6000 6500 6500 6920 9840 10240 10730 0 0 0 5000 5130 5280 5430 5570 5670 5800 5950 6150 \ D in num 0 0 0 0 0 0 0 0 0 0 306 314 323 332 341 347 353 364 376: replace eitc_exact_a=D/faminc if year==Y & children==0 & faminc>B & faminc<=C
for Y in num 1984/2002 \ B in num 5000 5000 5000 6080 6240 6500 6810 7140 7520 7750 7750 6160 6330 6500 6680 6800 6920 7140 7370 \ C in num 6000 6500 6500 6920 9840 10240 10730 11250 11840 12200 11000 11290 11610 11930 12260 12460 12700 13100 13550 \ D in num 500 550 550 851 874 910 953 1192 1324 1434 2038 2094 2152 2210 2271 2312 2353 2428 2506: replace eitc_exact_a=D/faminc if year==Y & children==1 & faminc>B & faminc<=C 
for Y in num 1984/2002 \ B in num 5000 5000 5000 6080 6240 6500 6810 7140 7520 7750 8425 8640 8890 9140 9390 9540 9720 10020 10350 \ C in num 6000 6500 6500 6920 9840 10240 10730 11250 11840 12200 11000 11290 11610 11930 12260 12460 12700 13100 13550 \ D in num 500 550 550 851 874 910 953 1235 1384 1511 2528 3110 3556 3656 3756 3816 3888 4008 4140: replace eitc_exact_a=D/faminc if year==Y & children>1 & children~=. & faminc>B & faminc<=C 

* Phaseout range
for Y in num 1984/2002 \ C in num 0 0 0 0 0 0 0 0 0 0 5000 5130 5280 5430 5570 5670 5800 5950 6150 \ D in num 0 0 0 0 0 0 0 0 0 0 306 314 323 332 341 347 353 364 376 \ E in num 0 0 0 0 0 0 0 0 0 0 7.65 7.65 7.65 7.65 7.65 7.65 7.65 7.65 7.65: replace eitc_exact_a=(D-(faminc-C)*(E/100))/faminc if year==Y & children==0 & faminc>C & faminc<=C+D*(100/E)
for Y in num 1984/2002 \ C in num 6000 6500 6500 6920 9840 10240 10730 11250 11840 12200 11000 11290 11610 11930 12260 12460 12700 13100 13550 \ D in num 500 550 550 851 874 910 953 1192 1324 1434 2038 2094 2152 2210 2271 2312 2353 2428 2506 \ E in num 12.5 12.22 12.22 10 10 10 10 11.93 12.57 13.21 15.98 15.98 15.98 15.98 15.98 15.98 15.98 15.98 15.98: replace eitc_exact_a=(D-(faminc-C)*(E/100))/faminc if year==Y & children==1 & faminc>C & faminc<=C+D*(100/E)
for Y in num 1984/2002 \ C in num 6000 6500 6500 6920 9840 10240 10730 11250 11840 12200 11000 11290 11610 11930 12260 12460 12700 13100 13550 \ D in num 500 550 550 851 874 910 953 1235 1384 1511 2528 3110 3556 3656 3756 3816 3888 4008 4140 \ E in num 12.5 12.22 12.22 10 10 10 10 12.36 13.14 13.93 17.68 20.22 21.06 21.06 21.06 21.06 21.06 21.06 21.06: replace eitc_exact_a=(D-(faminc-C)*(E/100))/faminc if year==Y & children>1 & children~=. & faminc>C & faminc<=C+D*(100/E)

replace eitc_exact_a=0 if year<=1993 & children==0
replace eitc_exact_a=. if faminc==.
replace eitc_exact_a=0 if eitc_exact_a==. & faminc~=.
la var eitc_exact_a "Own federal EITC rate (based on last year's family income)"

gen eitc_exact_m=.
* Phase-in range
for Y in num 1984/2002 \ A in num 0 0 0 0 0 0 0 0 0 0 7.65 7.65 7.65  7.65  7.65  7.65 7.65 7.65 7.65 \ B in num 5000 5000 5000 6080 6240 6500 6810 0 0 0 4000 4100 4220 4340 4460 4530 4610 4760 4910: replace eitc_exact_m=A/100 if year==Y & children==0 & faminc<=B
for Y in num 1984/2002 \ A in num 10 14 14 14 14 14 14 16.7 17.6 18.5 23.6 34 34 34 34 34 34 34 34 \ B in num 5000 5000 5000 6080 6240 6500 6810 7140 7520 7750 7750 6160 6330 6500 6680 6800 6920 7140 7370: replace eitc_exact_m=A/100 if year==Y & children==1 & faminc<=B 
for Y in num 1984/2002 \ A in num 10 14 14 14 14 14 14 17.3 18.4 19.5 30 36 40 40 40 40 40 40 40 \ B in num 5000 5000 5000 6080 6240 6500 6810 7140 7520 7750 8425 8640 8890 9140 9390 9540 9720 10020 10350: replace eitc_exact_m=A/100 if year==Y & children>1 & children~=. & faminc<=B 

* Phaseout range
for Y in num 1984/2002 \ C in num 0 0 0 0 0 0 0 0 0 0 5000 5130 5280 5430 5570 5670 5800 5950 6150 \ D in num 0 0 0 0 0 0 0 0 0 0 306 314 323 332 341 347 353 364 376 \ E in num 0 0 0 0 0 0 0 0 0 0 7.65 7.65 7.65 7.65 7.65 7.65 7.65 7.65 7.65: replace eitc_exact_m=-E/100 if year==Y & children==0 & faminc>C & faminc<=C+D*(100/E)
for Y in num 1984/2002 \ C in num 6000 6500 6500 6920 9840 10240 10730 11250 11840 12200 11000 11290 11610 11930 12260 12460 12700 13100 13550 \ D in num 500 550 550 851 874 910 953 1192 1324 1434 2038 2094 2152 2210 2271 2312 2353 2428 2506 \ E in num 12.5 12.22 12.22 10 10 10 10 11.93 12.57 13.21 15.98 15.98 15.98 15.98 15.98 15.98 15.98 15.98 15.98: replace eitc_exact_m=-E/100 if year==Y & children==1 & faminc>C & faminc<=C+D*(100/E)
for Y in num 1984/2002 \ C in num 6000 6500 6500 6920 9840 10240 10730 11250 11840 12200 11000 11290 11610 11930 12260 12460 12700 13100 13550 \ D in num 500 550 550 851 874 910 953 1235 1384 1511 2528 3110 3556 3656 3756 3816 3888 4008 4140 \ E in num 12.5 12.22 12.22 10 10 10 10 12.36 13.14 13.93 17.68 20.22 21.06 21.06 21.06 21.06 21.06 21.06 21.06: replace eitc_exact_m=-E/100 if year==Y & children>1 & children~=. & faminc>C & faminc<=C+D*(100/E)

replace eitc_exact_m=0 if year<=1993 & children==0
replace eitc_exact_m=. if faminc==.
replace eitc_exact_m=0 if eitc_exact_m==. & faminc~=.
la var eitc_exact_m "Own marginal federal EITC rate (based on last year's family income)"

* Replacing weights with integer weights
replace wgt=int(wgt)

compress
save morgC, replace

* VERSION 1: Starting with morgC, and creating a dataset (morgD) that only includes workers
clear
set mem 1200m
use morgC, clear

* Dropping Indiana
drop if stcode=="IN"

for any agesq s_agesq: replace X=X/100 
la var agesq "Age squared/100"
la var s_agesq "Spouse: Age squared/100"

drop if year<1984
ren wgt wgt_o
la var wgt_o "Original earnings weight"
bysort year: gen obsyear=_N if children~=.
gen obsavg=_N/19 if children~=.
gen wgt=wgt_o*(obsavg/obsyear)
la var wgt "Earnings weight balanced across years - obs with children nonmissing"
drop obsyear obsavg

gen eitcstate=1 if stcode=="CO" | stcode=="DC" | stcode=="IL" | stcode=="IA" | stcode=="KS" | stcode=="ME" | stcode=="MD" | stcode=="MA" | stcode=="MN" | stcode=="NJ" | stcode=="NY" | stcode=="OK" | stcode=="OR" | stcode=="RI" | stcode=="VT" | stcode=="WI"

*for num 0/3: gen childX_year=childX*year
gen child0_year=child0*(year-1983)
gen temp=1 if children>=1 & children~=.
recode temp .=0
gen child1_year=temp*(year-1983)
gen childyear=(year*10)+temp
drop temp

bysort year: egen temp1=mean(rminwage) if children~=. & adult==1
bysort year: egen temp2=sd(rminwage) if children~=. & adult==1
gen rminwage_s=(rminwage-temp1)/temp2
drop temp*
la var rminwage_s "Log real minimum wage (normalized to mean 0, SD 1 by year)"

gen kidsyes=1 if children>0 & children~=.
replace kidsyes=0 if children==0

drop if year<1984 | age<25 | age>55 | adult~=1

gen spouse=1 if s_age~=.
for any spouse s_age s_agesq s_ed_hsdropout s_ed_hsgrad s_ed_somecoll s_ed_college s_male s_black s_hispanic s_othrace s_black_male s_hispanic_male s_othrace_male: recode X .=0
gen married=1 if marital<4
recode married .=0
drop if married~=spouse

* Generating linear trend terms and interactions 
drop black_male hispanic_male othrace_male s_incwag
for any ed_hsdropout ed_hsgrad ed_somecoll ed_college black hispanic othrace: gen byte male_X=male*X
for var age agesq male* ed_* black hispanic othrace: gen m_X=spouse*X
*for var age agesq male* ed_* black hispanic othrace s_* m_*: gen yrX=(year-1983)*X
*for var age agesq male* ed_* black hispanic othrace s_* m_*: gen yrsqX=(((year-1983)*X)^2)/100

compress
note: TS - Full MORG dataset with unemployment, minimum wage, GSP, welfare, EITC rates, ind-occ codes, exact EITC 
sort stfips year
save morgD, replace

* VERSION 2: Starting with morgC, and creating a dataset (morgD2) that can be used to look at employment

use morgC if age>=25 & age<=55 & selfemp~=1, clear

drop adult singlewomen
gen adult=1 if age>=25 & age<=55 & selfemp~=1
recode adult .=0
gen singlewomen=1 if age>=25 & age<=55 & marital>3 & male==0 & selfemp~=1
recode singlewomen .=0
label var adult "Aged 25-55, not selfemp"
label var singlewomen "Single women aged 25-55, not selfemp "

* Dropping Indiana

drop if stcode=="IN"

for any agesq s_agesq: replace X=X/100 
la var agesq "Age squared/100"
la var s_agesq "Spouse: Age squared/100"

drop if year<1984
ren wgt wgt_o
la var wgt_o "Original earnings weight"
bysort year: gen obsyear=_N if children~=.
gen obsavg=_N/19 if children~=.
gen wgt=wgt_o*(obsavg/obsyear)
la var wgt "Earnings weight balanced across years - obs with children nonmissing"
drop obsyear obsavg

gen eitcstate=1 if stcode=="CO" | stcode=="DC" | stcode=="IL" | stcode=="IA" | stcode=="KS" | stcode=="ME" | stcode=="MD" | stcode=="MA" | stcode=="MN" | stcode=="NJ" | stcode=="NY" | stcode=="OK" | stcode=="OR" | stcode=="RI" | stcode=="VT" | stcode=="WI"

gen child0_year=child0*(year-1983)
gen temp=1 if children>=1 & children~=.
recode temp .=0
gen child1_year=temp*(year-1983)
gen childyear=(year*10)+temp
drop temp

bysort year: egen temp1=mean(rminwage) if children~=. & adult==1
bysort year: egen temp2=sd(rminwage) if children~=. & adult==1
gen rminwage_s=(rminwage-temp1)/temp2
drop temp*
la var rminwage_s "Log real minimum wage (normalized to mean 0, SD 1 by year)"

gen kidsyes=1 if children>0 & children~=.
replace kidsyes=0 if children==0

drop if year<1984 | age<25 | age>55 | adult~=1

gen spouse=1 if s_age~=.
for any spouse s_age s_agesq s_ed_hsdropout s_ed_hsgrad s_ed_somecoll s_ed_college s_male s_black s_hispanic s_othrace s_black_male s_hispanic_male s_othrace_male: recode X .=0
gen married=1 if marital<4
recode married .=0
drop if married~=spouse

* Generating trend terms and interactions 
drop black_male hispanic_male othrace_male s_incwag
for any ed_hsdropout ed_hsgrad ed_somecoll ed_college black hispanic othrace: gen byte male_X=male*X
for var age agesq male* ed_* black hispanic othrace: gen m_X=spouse*X

compress
note: TS - Full MORG dataset with unemployment, minimum wage, GSP, welfare, EITC rates, ind-occ codes, exact EITC. All adults � not just employed.
sort stfips year
save morgD2, replace

********************************************************
* Checking whether state EITC rates are associated with 
* the economy or other policy variables
********************************************************
clear
set mem 900m
cd "K:\EITC\"
use morgD2 if year>=1989 & year<=2002, clear
* Using log (weighted average of 1, 2 & 3 child rates) as a measure of generosity
* Weights are based on the fact that of those with kids, 40% have 1, 40% have 2, 20% have 3+.
gen generosity=.
for Y in num 1984/2002 \ A in num 0.578 0.598 0.609 0.631 0.658 0.689 0.727 0.757 0.780 0.803 0.824 0.847 0.872 0.892 0.906 0.926 0.957 0.984 1.000 \ D in num 500 550 550 851 874 910 953 1192 1324 1434 2038 2094 2152 2210 2271 2312 2353 2428 2506: replace generosity=ln(.4*((D*(1+eitc_s_child1))/A)+.4*((D*(1+eitc_s_child2))/A)+.2*((D*(1+eitc_s_child3))/A)) if year==Y

sort stcode
merge stcode using efile_intro_dates, keep(intro_efile intro_telefile intro_statefed) nokeep
tab _merge
drop _merge
for any efile telefile statefed: gen X=0 \ replace X=1 if year>=intro_X & intro_X~=.

collapse generosity eitc_s_child1 gsp_cap u rminwage maxbenefit welfarereform afdcwaiver statetax efile telefile statefed, by (stfips year)
tsset stfips year, yearly
xi: reg generosity gsp_cap u rminwage maxbenefit welfarereform afdcwaiver statetax efile telefile statefed i.year i.stfips, r cl(stfips)
outreg using table-eitcexog.doc, coefastr bracket se nocons 3aster replace ct("OLS 1989-2002") bdec(3)
xi: reg f.generosity gsp_cap u rminwage maxbenefit welfarereform afdcwaiver statetax efile telefile statefed i.year i.stfips, r cl(stfips)
outreg using table-eitcexog.doc, coefastr bracket se nocons 3aster append ct("OLS 1989-2002 (lagged)") bdec(3)

*******************************************************
* Creating new weights using the Abadie synthetic control method
* Ever had an EITC in 1989-2002 stfips = 8 11 17 19 20 23 24 25 27 34 36 40 41 44 50 55 
* Never had an EITC in 1989-2002 stfips = 1 2 4 5 6 9 10 12 13 15 16 21 22 26 28 29 30 31 32 33 35 37 38 39 42 45 46 47 48 49 51 53 54 56 
* Excluded: 18 (Indiana)
*******************************************************
* First, we determine the population share in each of the EITC states in 1984-88 (we'll need this later)
use "C:\Users\Andrew\EITC\gsp_pop.dta" if year>=1984 & year<=1988 & stfips>=1 & stfips<=56, clear
for num 1 2 4 5 6 9 10 12 13 15 16 21 22 26 28 29 30 31 32 33 35 37 38 39 42 45 46 47 48 49 51 53 54 56: drop if stfips==X
bysort stfips: egen poptotal=sum(pop)
egen tag=tag(stfips)
keep if tag
egen pop_us=sum(poptotal)
gen popshare=poptotal/pop_us
keep stfips popshare
gen n=1
reshape wide popshare,i(n) j(stfips)
drop n
expand 56
gen _Co_Number=_n
sort _Co_Number
cd "K:\EITC\"
save temp_popshare, replace

* Now, we create weights for each of the treatment states, and save each set of weights in a separate temp_synth file
clear
set mem 900m
cd "K:\EITC\"
use morgD2 if year<=1989, clear
collapse state lwage eitc_s_child1 gsp_cap u rminwage maxbenefit welfarereform afdcwaiver statetax , by (stfips year)
save temp1_for_synth, replace
tsset stfips year, yearly
#delimit ;
for num 8 11 17 19 20 23 24 25 27 34 36 40 41 44 50 55: 
synth lwage gsp_cap u rminwage maxbenefit statetax,
counit(1 2 4 5 6 9 10 12 13 15 16 21 22 26 28 29 30 31 32 33 35 37 38 39 42 45 46 47 48 49 51 53 54 56) 
trunit(X) trperiod(1989) keep(temp_synth_X,replace);
#delimit cr
for num 8 11 17 19 20 23 24 25 27 34 36 40 41 44 50 55: use temp_synth_X, clear \ ren _W_Weight weightX \ sort _Co_Number \ save temp_synth_X, replace

* Now, we combine the temp_synth files, and aggregate the weights in proportion to the population in the treatment states
use _Co_Number weight8 using temp_synth_8,clear
for num 11 17 19 20 23 24 25 27 34 36 40 41 44 50 55: sort _Co_Number \ merge _Co_Number using temp_synth_X,keep(weightX) \ drop _merge
sort _Co_Number
merge _Co_Number using temp_popshare, nokeep
tab _merge
drop _merge
ren _Co_Number stfips
gen weight_synth=weight8*popshare8
for num 11 17 19 20 23 24 25 27 34 36 40 41 44 50 55: replace weight_synth=weight_synth+(weightX*popshareX)
list stfips weight_synth
* Now, we ensure that the mean of the synth weights is 1 (we'll give this weight to all treatment group observations)
sum weight_synth
replace weight_synth=weight_synth/r(mean)
keep stfips weight_synth
sort stfips
save weight_synth, replace
* The final set of weights gives more weight to a control group state: 
* (a) the more its wages tracked a treatment group state in 1984-88, and
* (b) the bigger was the population of that treatment group state in 1984-88.

*********************************************
* State EITCs � EMPLOYMENT EFFECTS 
* >> Recoded July 2007
*********************************************
clear
set more off
set mem 1200m
cd "K:\EITC\"
use morgD2 if year>=1989 & year<=2002, clear
gen lnhours=ln(uhourse)
replace wgt=int(wgt)
recode wgt min/0=0

drop m_ed_hsdropout m_male_ed_hsdropout male_ed_hsdropout
gen child_year=year*10 if children==0
replace child_year=year*10+1 if children>=1 & children<.
tab child_year, gen(child_year_)
tab children, gen(children_)

sort stcode
merge stcode using efile_intro_dates, keep(intro_efile intro_telefile intro_statefed) nokeep
tab _merge
drop _merge
for any efile telefile statefed: gen X=0 \ replace X=1 if year>=intro_X & intro_X~=.

gen generosity=.
* Using log (weighted average of 1, 2 & 3 child rates) divided by 1920 as a measure of generosity
* Weights are based on the fact that of those with kids, 40% have 1, 40% have 2, 20% have 3+.
for Y in num 1984/2002 \ A in num 0.578 0.598 0.609 0.631 0.658 0.689 0.727 0.757 0.780 0.803 0.824 0.847 0.872 0.892 0.906 0.926 0.957 0.984 1.000 \ D in num 500 550 550 851 874 910 953 1192 1324 1434 2038 2094 2152 2210 2271 2312 2353 2428 2506: replace generosity=ln((.4*((D*(1+eitc_s_child1))/A)+.4*((D*(1+eitc_s_child2))/A)+.2*((D*(1+eitc_s_child3))/A))/1920) if year==Y

* What is the EITC worth to the typical dropout?
gen eitc_dollars=exp(generosity)
gen wage_dollars=exp(lwage)
sum eitc_dollars wage_dollars if ed_hsdropout==1 & kidsyes==1 & eitc_dollars~=. & wage_dollars~=. [w=wgt]
di "0.1 increase in EITC is"
di (eitc_dollars*.1)/wage_dollars
di "increase in wages"
drop eitc_dollars wage_dollars

global controls "efile telefile statefed u rminwage maxbenefit welfarereform afdcwaiver statetax male age agesq black hispanic othrace male_black male_hispanic male_othrace ed_hsgrad ed_somecoll ed_college s_* child_year_* children_* i.state"

for X in any adult: xi: reg employed generosity $controls [w=wgt] if X==1 & kidsyes~=., robust cluster(state) \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster replace ct("Employed - X. Kids & NoKids") bdec(3) 
for X in any ed_hsdropout ed_hsgrad ed_college: xi: reg employed generosity $controls [w=wgt] if X==1 & kidsyes~=., robust cluster(state) \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster append ct("Employed - X. Kids & NoKids") bdec(3) 
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: reg employed generosity $controls [w=wgt] if X==1 & kidsyes==1, robust cluster(state) \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster append ct("Employed - X. Kids") bdec(3) 
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: reg employed generosity $controls [w=wgt] if X==1 & kidsyes==0, robust cluster(state) \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster append ct("Employed - X. NoKids.") bdec(3) 
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: reg lnhours generosity $controls [aw=wgt] if X==1 & kidsyes~=., robust cluster(state) \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster append ct("Log hours - X. Kids & NoKids") bdec(3)
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: reg lnhours generosity $controls [aw=wgt] if X==1 & kidsyes==1, robust cluster(state) \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster append ct("Log hours - X. Kids") bdec(3)
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: reg lnhours generosity $controls [aw=wgt] if X==1 & kidsyes==0, robust cluster(state) \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster append ct("Log hours - X. NoKids") bdec(3)

* Robustness check - looking at employment with probit rather than linear probability.
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: dprobit employed generosity $controls [fw=wgt] if X==1 & kidsyes~=., robust cluster(state) \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster append ct("Employed probit - X. Kids & NoKids") bdec(3) 
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: dprobit employed generosity $controls [fw=wgt] if X==1 & kidsyes==1, robust cluster(state) \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster append ct("Employed probit - X. Kids") bdec(3) 
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: dprobit employed generosity $controls [fw=wgt] if X==1 & kidsyes==0, robust cluster(state) \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster append ct("Employed probit - X. NoKids.") bdec(3) 

* Robustness check - comparison with federal specification
gen temp=eitc_exact_a
recode temp .=. 0=0 *=1
bysort state year: egen eitcyes=mean(temp)
for X in any employed lnhours lwage: xi: ivreg2 X (eitcyes=generosity) $controls [w=wgt] if adult==1 & kidsyes~=., first robust cluster(state) \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster append ct("X - All. Share IV.") bdec(3) 
drop temp eitcyes

* IV specification, with state variation used to instrument individual eligibility
gen faminc_real=.
for Y in num 1984/2002 \ A in num 0.578 0.598 0.609 0.631 0.658 0.689 0.727 0.757 0.780 0.803 0.824 0.847 0.872 0.892 0.906 0.926 0.957 0.984 1.000: replace faminc_real=faminc/A if year==Y
gen eitc_exact_amount=eitc_exact_a*faminc_real*(1+eitc_s_child0) if children==0
replace eitc_exact_amount=eitc_exact_a*faminc_real*(1+eitc_s_child1) if children==1
replace eitc_exact_amount=eitc_exact_a*faminc_real*(1+eitc_s_child2) if children>=2 & children~=.
recode eitc_exact_amount min/-1=.
replace eitc_exact_amount=ln(1+eitc_exact_amount)
gen generosity_iv=ln(1+(1920*exp(generosity)))
log using iv_specification, replace
for X in any employed lnhours lwage: xi: ivreg2 X generosity $controls [w=wgt] if adult==1 & kidsyes~=. & eitc_exact_amount~=., robust cluster(state) \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster append ct("IV sample X. Kids & NoKids") bdec(3) 
for X in any employed lnhours lwage: xi: ivreg2 X (eitc_exact_amount=generosity_iv) $controls [w=wgt] if adult==1 & kidsyes~=., robust cluster(state) first \ outreg using table-state-emp-1.doc, coefastr bracket se nocons 3aster append ct("IV X. Kids & NoKids") bdec(3) 
log close

* Calculating employment rates
sum employed if ed_hsdropout==1 & kidsyes~=. [w=wgt]

* Summary statistics
xi: reg employed generosity $controls [w=wgt] if adult==1 & kidsyes~=., robust cluster(state)
tabstat employed lnhours lwage generosity gsp_cap u rminwage maxbenefit welfarereform afdcwaiver statetax efile telefile statefed male age black hispanic othrace ed_hsdropout ed_hsgrad ed_college children married [w=wgt] if e(sample), stat(mean sd n) c(s) nosep

* Calculating the fraction of EITC eligibles in each population subgroup 
* Note that this uses MarchMORG
use marchmorgD2 if year>=1989 & year<=2002, clear
gen eitc_yesno=eitc_exact_a
recode eitc_yesno 0=0 .=. *=1
for any adult ed_hsdropout ed_hsgrad ed_college: sum eitc_yesno if X==1 & employed~=. & kidsyes~=. [w=wgt]
for any adult ed_hsdropout ed_hsgrad ed_college: sum eitc_yesno if X==1 & employed==1 & kidsyes~=. [w=wgt]
for any adult ed_hsdropout ed_hsgrad ed_college: sum eitc_yesno if X==1 & employed~=. & kidsyes==1 [w=wgt]
for any adult ed_hsdropout ed_hsgrad ed_college: sum eitc_yesno if X==1 & employed~=. & kidsyes==0 [w=wgt]
for any adult ed_hsdropout ed_hsgrad ed_college: sum eitc_yesno if X==1 & employed==1 & kidsyes==1 [w=wgt]
for any adult ed_hsdropout ed_hsgrad ed_college: sum eitc_yesno if X==1 & employed==1 & kidsyes==0 [w=wgt]

*********************************************
* Simple scatterplot graphs
* Using morg_d2 (which contains all adults, not just workers)
* >> Recoded July 2007
*********************************************
clear
set more off
set mem 300m
cd "K:\EITC\"
use morgD2 if ed_hsdropout==1 & year>=1989 & year<=2002, clear
drop m_ed_hsdropout m_male_ed_hsdropout male_ed_hsdropout
gen generosity=.
* Using log (weighted average of 1, 2 & 3 child rates) as a measure of generosity
* Weights are based on the fact that of those with kids, 40% have 1, 40% have 2, 20% have 3+.
for Y in num 1984/2002 \ A in num 0.578 0.598 0.609 0.631 0.658 0.689 0.727 0.757 0.780 0.803 0.824 0.847 0.872 0.892 0.906 0.926 0.957 0.984 1.000 \ D in num 500 550 550 851 874 910 953 1192 1324 1434 2038 2094 2152 2210 2271 2312 2353 2428 2506: replace generosity=ln(.4*((D*(1+eitc_s_child1))/A)+.4*((D*(1+eitc_s_child2))/A)+.2*((D*(1+eitc_s_child3))/A)) if year==Y
recode year 1989/1990=1990 2001/2002=2002 *=.
drop if year==.
gen wage=(earnwke/uhourse)/cpi
gen weeklyhours=uhourse
recode weeklyhours .=0

*gen child_year=year*10 if children==0
*replace child_year=year*10+1 if children>=1 & children<.
*tab child_year, gen(child_year_)
*tab children, gen(children_)

sort stcode
merge stcode using efile_intro_dates, keep(intro_efile intro_telefile intro_statefed) nokeep
tab _merge
drop _merge
for any efile telefile statefed: gen X=0 \ replace X=1 if year>=intro_X & intro_X~=.

* Creating residuals
global controls "efile telefile statefed u rminwage maxbenefit welfarereform afdcwaiver statetax male age agesq black hispanic othrace male_black male_hispanic male_othrace ed_hsgrad ed_somecoll ed_college s_* i.children"
gen lweeklyhours=ln(weeklyhours)
for X in any employed lwage lweeklyhours : xi: reg X $controls [w=wgt] if kidsyes==0, robust cluster(state) \ predict temp if e(sample), resid \ xi: reg X $controls [w=wgt] if kidsyes==1, robust cluster(state) \ predict X_resid if e(sample), resid \ replace X_resid=temp if X_resid==. \ drop temp
drop lweeklyhours

collapse employed_resid lwage_resid lweeklyhours_resid eitc_s_child1 wage faminc weeklyhours employed generosity u rminwage maxbenefit welfarereform afdcwaiver statetax (count) N=lwage [w=wgt], by(state year kidsyes)
save temp_for_figs_3-5,replace
use temp_for_figs_3-5,clear
sum N
*gen lfaminc=ln(faminc)
gen lwage=ln(wage)
gen lweeklyhours=ln(weeklyhours)

for any employed_resid lwage_resid lweeklyhours_resid eitc_s_child1 generosity lwage lweeklyhours employed: gen temp1=X if year>=1990 & year<=1991 \ bysort state kidsyes: egen temp2=max(temp1) \ gen temp3=X if year>=2001 & year<=2002 \ bysort state kidsyes: egen temp4=max(temp3) \ gen dX=temp4-temp2 if year==2002 \ drop temp*
label define _state 11 ME 12 NH 13 VT 14 MA 15 RI 16 CT 21 NY 22 NJ 23 PA 31 OH 32 IN 33 IL 34 MI 35 WI 41 MN 42 IA 43 MO 44 ND 45 SD 46 NE 47 KS 51 DE 52 MD 53 DC 54 VA 55 WV 56 NC 57 SC 58 GA 59 FL 61 KY 62 TN 63 AL 64 MS 71 AR 72 LA 73 OK 74 TX 81 MT 82 ID 83 WY 84 CO 85 NM 86 AZ 87 UT 88 NV 91 WA 92 OR 93 CA 94 AK 95 HI
label values state _state
set scheme s1mono
tw scatter demployed dgenerosity if kidsyes==1,mlabel(state) || lfit demployed dgenerosity if kidsyes==1 [aw=N], ysc(r(-.2 .3)) ylabel(-.2 0 .2 ) legend(off) yti("Change in participation rate") xti("Change in log EITC generosity") ti("With Children") name(emp1,replace) nodraw 
tw scatter demployed dgenerosity if kidsyes==0,mlabel(state) || lfit demployed dgenerosity if kidsyes==0 [aw=N], ysc(r(-.2 .3)) ylabel(-.2 0 .2 ) legend(off) yti("Change in participation rate") xti("Change in log EITC generosity") ti("Without Children") name(emp0,replace) nodraw 
gr combine emp1 emp0, ti("Figure 3: State EITCs and Employment") note("Charts show high school dropouts only. Change is from 1989/90 to 2001/02." "Regression lines are weighted by sample size.") 
tw scatter dlweeklyhours dgenerosity if kidsyes==1 ,mlabel(state) || lfit dlweeklyhours dgenerosity if kidsyes==1 [aw=N], ysc(r(-.4 .4)) ylabel(-.4 0 .4) legend(off) yti("Change in log weekly hours") xti("Change in log EITC generosity") ti("With Children") name(wkhrs1,replace) nodraw 
tw scatter dlweeklyhours dgenerosity if kidsyes==0 ,mlabel(state) || lfit dlweeklyhours dgenerosity if kidsyes==0 [aw=N], ysc(r(-.4 .4)) ylabel(-.4 0 .4) legend(off) yti("Change in log weekly hours") xti("Change in log EITC generosity") ti("Without Children") name(wkhrs0,replace) nodraw 
gr combine wkhrs1 wkhrs0, ti("Figure 4: State EITCs and Log Hours") note("Charts show high school dropouts only. Change is from 1989/90 to 2001/02." "Regression lines are weighted by sample size.") 
tw scatter dlwage dgenerosity if kidsyes==1,mlabel(state) || lfit dlwage dgenerosity if kidsyes==1 [aw=N], ysc(r(-.4 .4)) ylabel(-.4 0 .4) legend(off) yti("Change in log hourly wage") xti("Change in log EITC generosity") ti("With Children") name(wage1,replace) nodraw 
tw scatter dlwage dgenerosity if kidsyes==0 ,mlabel(state) || lfit dlwage dgenerosity if kidsyes==0 & dlwage>-1 [aw=N], ysc(r(-.4 .4)) ylabel(-.4 0 .4) legend(off) yti("Change in log hourly wage") xti("Change in log EITC generosity") ti("Without Children") name(wage0,replace) nodraw 
gr combine wage1 wage0, ti("Figure 5: State EITCs and Hourly Wages") note("Charts show high school dropouts only. Change is from 1989/90 to 2001/02." "Regression lines are weighted by sample size.") 

* Residual graphs
tw scatter demployed_resid dgenerosity if kidsyes==1,mlabel(state) || lfit demployed_resid  dgenerosity if kidsyes==1 [aw=N], ysc(r(-.2 .3)) ylabel(-.2 0 .2 ) legend(off) yti("Change in participation rate (residual)") xti("Change in log EITC generosity") ti("With Children") name(emp1,replace) nodraw 
tw scatter demployed_resid  dgenerosity if kidsyes==0,mlabel(state) || lfit demployed_resid  dgenerosity if kidsyes==0 [aw=N], ysc(r(-.2 .3)) ylabel(-.2 0 .2 ) legend(off) yti("Change in participation rate (residual)") xti("Change in log EITC generosity") ti("Without Children") name(emp0,replace) nodraw 
gr combine emp1 emp0, ti("Figure 3: State EITCs and Employment") note("Charts show high school dropouts only. Change is from 1989/90 to 2001/02." "Regression lines are weighted by sample size.") 
tw scatter dlweeklyhours_resid  dgenerosity if kidsyes==1 ,mlabel(state) || lfit dlweeklyhours_resid  dgenerosity if kidsyes==1 [aw=N], ysc(r(-.4 .4)) ylabel(-.4 0 .4) legend(off) yti("Change in log weekly hours (residual)") xti("Change in log EITC generosity") ti("With Children") name(wkhrs1,replace) nodraw 
tw scatter dlweeklyhours_resid  dgenerosity if kidsyes==0 ,mlabel(state) || lfit dlweeklyhours_resid  dgenerosity if kidsyes==0 [aw=N], ysc(r(-.4 .4)) ylabel(-.4 0 .4) legend(off) yti("Change in log weekly hours (residual)") xti("Change in log EITC generosity") ti("Without Children") name(wkhrs0,replace) nodraw 
gr combine wkhrs1 wkhrs0, ti("Figure 4: State EITCs and Log Hours") note("Charts show high school dropouts only. Change is from 1989/90 to 2001/02." "Regression lines are weighted by sample size.") 
tw scatter dlwage_resid  dgenerosity if kidsyes==1,mlabel(state) || lfit dlwage_resid  dgenerosity if kidsyes==1 [aw=N], ysc(r(-.4 .4)) ylabel(-.4 0 .4) legend(off) yti("Change in log hourly wage (residual)") xti("Change in log EITC generosity") ti("With Children") name(wage1,replace) nodraw 
tw scatter dlwage_resid  dgenerosity if kidsyes==0 ,mlabel(state) || lfit dlwage_resid  dgenerosity if kidsyes==0 & dlwage>-1 [aw=N], ysc(r(-.4 .4)) ylabel(-.4 0 .4) legend(off) yti("Change in log hourly wage (residual)") xti("Change in log EITC generosity") ti("Without Children") name(wage0,replace) nodraw 
gr combine wage1 wage0, ti("Figure 5: State EITCs and Hourly Wages") note("Charts show high school dropouts only. Change is from 1989/90 to 2001/02." "Regression lines are weighted by sample size.") 

for any demployed dlweeklyhours dlwage: reg X dgenero if kidsyes==1, cl(state) 
reg dlwage dgenero if eitc_s_child1>0, cl(state)

for num 0/1: reg dlfaminc dgenero if kidsyes==X [aw=N] \ reg dlweeklyhours dgenero if kidsyes==X [aw=N]

*********************************************
* Event study graphs
* Using morg_d2 (which contains all adults, not just workers)
*********************************************
clear
set more off
set mem 300m
cd "K:\EITC\"
use morgD2 if ed_hsdropout==1 & year>=1989 & year<=2002, clear
* Generating an 'EITC year' variable
gen eitc_start=.
for num 11 14 21 22 33 41 47 52 53 73 84 92 \ num 2000 1997 1994 2000 2000 1991 1998 1998 2000 2002 1999 1997: replace eitc_start=Y if state==X
gen eitc_year=year-eitc_start
gen lnhours=ln(uhourse)
gen wage=exp(lwage)
preserve
gen employed_rel=.
for num 11 14 21 22 33 41 47 52 53 73 84 92: bysort year: egen temp1=mean(employed) if state==X \ bysort year: egen temp2=mean(employed) if eitcstate==. \ bysort year: egen temp3=max(temp2) \ replace employed_rel=temp1/temp3 if state==X \ drop temp*
gen lwage_rel=.
for num 11 14 21 22 33 41 47 52 53 73 84 92: bysort year: egen temp1=mean(wage) if state==X \ bysort year: egen temp2=mean(wage) if eitcstate==. \ bysort year: egen temp3=max(temp2) \ replace lwage_rel=temp1/temp3 if state==X \ drop temp*
gen lnhours_rel=.
for num 11 14 21 22 33 41 47 52 53 73 84 92: bysort year: egen temp1=mean(uhourse) if state==X & uhourse>0 \ bysort year: egen temp2=mean(uhourse) if eitcstate==. & uhourse>0 \ bysort year: egen temp3=max(temp2) \ replace lnhours_rel=temp1/temp3 if state==X \ drop temp*
drop if eitc_year==. 

collapse eitc_s_child1 lwage employed employed_rel lwage_rel lnhours_rel u rminwage maxbenefit welfarereform afdcwaiver statetax (count) N=lwage (p10) employed_rel_p5=employed_rel lwage_rel_p5=lwage_rel lnhours_rel_p5=lnhours_rel (p90) employed_rel_p95=employed_rel lwage_rel_p95=lwage_rel lnhours_rel_p95=lnhours_rel [w=wgt], by(eitc_year)
for any employed_rel lnhours_rel lwage_rel \ num .0289 .0033 .0188: replace X_p5=X-1.96*Y \ replace X_p95=X+1.96*Y
sum N
sort eitc_year
set scheme s1mono
keep if eitc_year>=-5 & eitc_year<=5
for any employed_rel lnhours_rel lwage_rel: egen X_bef=mean(X) if eitc_year<=-1 \ egen X_aft=mean(X) if eitc_year>=0 
tw line employed_rel eitc_year || line employed_rel_bef eitc_year, lpattern(solid) lwidth(thick) || line employed_rel_aft eitc_year, lpattern(solid) lwidth(thick) xlabel(-5 -5 -4 -4 -3 -3 -2 -2 -1 -1 0 "0" 1 "+1" 2 "+2" 3 "+3" 4 "+4" 5 "+5", grid ) ylab(#3) xti("") yti("") ti("Employment Rate") name(emp,replace) legend(off) nodraw
tw line lnhours_rel eitc_year || line lnhours_rel_bef eitc_year, lpattern(solid) lwidth(thick) || line lnhours_rel_aft eitc_year, lpattern(solid) lwidth(thick) xlabel(-5 -5 -4 -4 -3 -3 -2 -2 -1 -1 0 "0" 1 "+1" 2 "+2" 3 "+3" 4 "+4" 5 "+5", grid ) ylab(#3) xti("") yti("") ti("Hours Worked") name(hours, replace) legend(off) nodraw
tw line lwage_rel eitc_year || line lwage_rel_bef eitc_year, lpattern(solid) lwidth(thick) || line lwage_rel_aft eitc_year, lpattern(solid) lwidth(thick) xlabel(-5 -5 -4 -4 -3 -3 -2 -2 -1 -1 0 "0" 1 "+1" 2 "+2" 3 "+3" 4 "+4" 5 "+5", grid ) ylab(#3) xti("") yti("") ti("Hourly Wage") name(wage, replace) legend(off) nodraw
gr combine emp hours wage, ti("Figure 6: Effect Over Time of Introducing a State EITC") note("Note: Sample is high school dropouts in states with EITCs. Year 0 is the year that a state EITC was introduced." "Graphs show the ratio of the employment rate, hours and hourly wages in states that introduced an EITC," "relative to states that never had an EITC in the same calendar year.")

restore
sort stfips
merge stfips using weight_synth
drop _merge
sum wgt if weight_synth==.
replace wgt=wgt/r(mean) if weight_synth==.
replace wgt=wgt*weight_synth if weight_synth~=.
sum wgt if weight_synth~=.
replace wgt=wgt/r(mean) if weight_synth~=.

* This code will only run if you've installed _gwtmean (ssc install _gwtmean)
gen employed_rel=.
#delimit ;
for num 11 14 21 22 33 41 47 52 53 73 84 92: sort year \ 
egen temp1=wtmean(employed) if state==X, by(year) weight(wgt) \ 
egen temp2=wtmean(employed) if eitcstate==.,by(year) weight(wgt) \ 
bysort year: egen temp3=max(temp2) \ replace employed_rel=temp1/temp3 if state==X \ drop temp*;
gen lwage_rel=.;
for num 11 14 21 22 33 41 47 52 53 73 84 92: 
egen temp1=wtmean(wage) if state==X, by(year) weight(wgt) \ 
egen temp2=wtmean(wage) if eitcstate==.,by(year) weight(wgt) \ 
bysort year: egen temp3=max(temp2) \ replace lwage_rel=temp1/temp3 if state==X \ drop temp*;
gen lnhours_rel=.;
for num 11 14 21 22 33 41 47 52 53 73 84 92: 
egen temp1=wtmean(uhourse) if state==X & uhourse>0, by(year) weight(wgt) \ 
egen temp2=wtmean(uhourse) if eitcstate==. & uhourse>0,by(year) weight(wgt) \ 
bysort year: egen temp3=max(temp2) \ replace lnhours_rel=temp1/temp3 if state==X \ drop temp*;
#delimit cr

drop if eitc_year==. 
collapse eitc_s_child1 lwage employed employed_rel lwage_rel lnhours_rel u rminwage maxbenefit welfarereform afdcwaiver statetax (count) N=lwage (p10) employed_rel_p5=employed_rel lwage_rel_p5=lwage_rel lnhours_rel_p5=lnhours_rel (p90) employed_rel_p95=employed_rel lwage_rel_p95=lwage_rel lnhours_rel_p95=lnhours_rel [w=wgt], by(eitc_year)
for any employed_rel lnhours_rel lwage_rel \ num .0289 .0033 .0188: replace X_p5=X-1.96*Y \ replace X_p95=X+1.96*Y
sum N
sort eitc_year
set scheme s1mono
keep if eitc_year>=-5 & eitc_year<=5
for any employed_rel lnhours_rel lwage_rel: egen X_bef=mean(X) if eitc_year<=-1 \ egen X_aft=mean(X) if eitc_year>=0 
tw line employed_rel eitc_year || line employed_rel_bef eitc_year, lpattern(solid) lwidth(thick) || line employed_rel_aft eitc_year, lpattern(solid) lwidth(thick) xlabel(-5 -5 -4 -4 -3 -3 -2 -2 -1 -1 0 "0" 1 "+1" 2 "+2" 3 "+3" 4 "+4" 5 "+5", grid ) ylab(#3) xti("") yti("") ti("Employment Rate") name(emp,replace) legend(off) nodraw
tw line lnhours_rel eitc_year || line lnhours_rel_bef eitc_year, lpattern(solid) lwidth(thick) || line lnhours_rel_aft eitc_year, lpattern(solid) lwidth(thick) xlabel(-5 -5 -4 -4 -3 -3 -2 -2 -1 -1 0 "0" 1 "+1" 2 "+2" 3 "+3" 4 "+4" 5 "+5", grid ) ylab(#3) xti("") yti("") ti("Hours Worked") name(hours, replace) legend(off) nodraw
tw line lwage_rel eitc_year || line lwage_rel_bef eitc_year, lpattern(solid) lwidth(thick) || line lwage_rel_aft eitc_year, lpattern(solid) lwidth(thick) xlabel(-5 -5 -4 -4 -3 -3 -2 -2 -1 -1 0 "0" 1 "+1" 2 "+2" 3 "+3" 4 "+4" 5 "+5", grid ) ylab(#3) xti("") yti("") ti("Hourly Wage") name(wage, replace) legend(off) nodraw
gr combine emp hours wage, ti("Figure X: Effect Over Time of Introducing a State EITC") subti("Control states weighted using synthetic control approach") note("Note: Sample is high school dropouts in states with EITCs. Year 0 is the year that a state EITC was introduced." "Graphs show the ratio of the employment rate, hours and hourly wages in states that introduced an EITC," "relative to states that never had an EITC in the same calendar year." "Synthetic control approach follows Abadie, Diamond, and Hainmueller (2007). See text for details.")

*****************************************************
* State EITCs - hourly wages
* >> Recoded July 2007
*****************************************************
clear
set more off
set matsize 800
set mem 1200m
cd "K:\EITC\"
use morgD if lwage~=. & year>=1989 & adult==1 & children~=., clear
drop m_ed_hsdropout m_male_ed_hsdropout male_ed_hsdropout
recode wgt min/0=0
gen child_year=year*10 if children==0
replace child_year=year*10+1 if children>=1 & children<.
tab child_year, gen(child_year_)
tab children, gen(children_)

sort stcode
merge stcode using efile_intro_dates, keep(intro_efile intro_telefile intro_statefed) nokeep
tab _merge
drop _merge
for any efile telefile statefed: gen X=0 \ replace X=1 if year>=intro_X & intro_X~=.

gen generosity=.
* Using log (weighted average of 1, 2 & 3 child rates) divided by 1920 as a measure of generosity
* Weights are based on the fact that of those with kids, 40% have 1, 40% have 2, 20% have 3+.
for Y in num 1984/2002 \ A in num 0.578 0.598 0.609 0.631 0.658 0.689 0.727 0.757 0.780 0.803 0.824 0.847 0.872 0.892 0.906 0.926 0.957 0.984 1.000 \ D in num 500 550 550 851 874 910 953 1192 1324 1434 2038 2094 2152 2210 2271 2312 2353 2428 2506: replace generosity=ln((.4*((D*(1+eitc_s_child1))/A)+.4*((D*(1+eitc_s_child2))/A)+.2*((D*(1+eitc_s_child3))/A))/1920) if year==Y

* No time interactions
global controls "efile telefile statefed u rminwage maxbenefit welfarereform afdcwaiver statetax male age agesq black hispanic othrace male_black male_hispanic male_othrace ed_hsgrad ed_somecoll ed_college s_* child_year_* children_*"
for X in any adult: xi: areg lwage generosity $controls [w=wgt] if X==1, cluster(state) a(state) \ outreg using table-state-1.doc, coefastr bracket se nocons 3aster replace ct("X - No time inter") bdec(3)
for X in any ed_hsdropout ed_hsgrad ed_college: xi: areg lwage generosity $controls [w=wgt] if X==1, robust cluster(state) absorb(state) \ outreg using table-state-1.doc, coefastr bracket se nocons 3aster append ct("X - No time inter") bdec(3)
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: areg lwage generosity $controls [w=wgt] if X==1 & kidsyes==1, robust cluster(state) absorb(state) \ outreg using table-state-1.doc, coefastr bracket se nocons 3aster append ct("X - No time inter. Kids") bdec(3)
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: areg lwage generosity $controls [w=wgt] if X==1 & kidsyes==0, robust cluster(state) absorb(state) \ outreg using table-state-1.doc, coefastr bracket se nocons 3aster append ct("X - No time inter. No kids") bdec(3)

* Robustness Checks
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: areg lwage generosity gsp_cap $controls [w=wgt] if X==1, robust cluster(state) a(state) \ outreg using table-state-1.doc, coefastr bracket se nocons 3aster append ct("X - With GSP") bdec(3)
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: areg lwage generosity $controls [w=wgt] if X==1 & eitcstate==1, robust cluster(state) a(state) \ outreg using table-state-1.doc, coefastr bracket se nocons 3aster append ct("X - Drop non-EITC states") bdec(3)
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: areg lwage generosity $controls [w=wgt] if X==1 & eitc_s_refundable~=0, robust cluster(state) a(state) \ outreg using table-state-1.doc, coefastr bracket se nocons 3aster append ct("X - Drop nonrefundable EITCs") bdec(3)
save temp2_for_synth, replace
replace generosity=.
for Y in num 1984/2002 \ A in num 0.578 0.598 0.609 0.631 0.658 0.689 0.727 0.757 0.780 0.803 0.824 0.847 0.872 0.892 0.906 0.926 0.957 0.984 1.000 \ D in num 500 550 550 851 874 910 953 1192 1324 1434 2038 2094 2152 2210 2271 2312 2353 2428 2506: replace generosity=ln(((D*(1+eitc_s_child1))/A)/1920) if year==Y
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: areg lwage generosity $controls [w=wgt] if X==1, robust cluster(state) a(state) \ outreg using table-state-1.doc, coefastr bracket se nocons 3aster append ct("X - One-child EITC") bdec(3)

* With synthetic control approach - not bootstrapped
sort stfips
merge stfips using weight_synth
drop _merge
sum wgt if weight_synth==.
replace wgt=wgt/r(mean) if weight_synth==.
replace wgt=wgt*weight_synth if weight_synth~=.
sum wgt if weight_synth~=.
replace wgt=wgt/r(mean) if weight_synth~=.
for X in any adult ed_hsdropout ed_hsgrad ed_college: xi: areg lwage generosity $controls [w=wgt] if X==1, robust cluster(state) a(state) \ outreg using table-state-1.doc, coefastr bracket se nocons 3aster append ct("X - Synthetic Control approach") bdec(3)

* With synthetic control approach - bootstrapped
clear
set more off
set matsize 800
set mem 1200m
cd "K:\EITC\"
prog drop _all
prog def synth_bootstrap
	tsset stfips year, yearly
	#delimit ;
	for num 8 11 17 19 20 23 24 25 27 34 36 40 41 44 50 55: 
	synth lwage gsp_cap u rminwage maxbenefit statetax,
	counit(1 2 4 5 6 9 10 12 13 15 16 21 22 26 28 29 30 31 32 33 35 37 38 39 42 45 46 47 48 49 51 53 54 56) 
	trunit(X) trperiod(1989) customV($a $b $c $d $e) keep(temp_synth_X,replace);
	#delimit cr
	for num 8 11 17 19 20 23 24 25 27 34 36 40 41 44 50 55: use temp_synth_X, clear \ ren _W_Weight weightX \ sort _Co_Number \ save temp_synth_X, replace
	use _Co_Number weight8 using temp_synth_8
	for num 11 17 19 20 23 24 25 27 34 36 40 41 44 50 55: merge _Co_Number using temp_synth_X,keep(weightX) \ drop _merge \ sort _Co_Number
	sort _Co_Number
	merge _Co_Number using temp_popshare
	tab _merge
	drop _merge
	ren _Co_Number stfips
	gen weight_synth=weight8*popshare8
	for num 11 17 19 20 23 24 25 27 34 36 40 41 44 50 55: replace weight_synth=weight_synth+(weightX*popshareX)
	list stfips weight_synth
	sum weight_synth
	replace weight_synth=weight_synth/r(mean)
	keep stfips weight_synth
	sort stfips
end

set seed 12345678
forvalues i = 1(1)100 {
	use temp1_for_synth,clear
	global a=runiform()
	global b=runiform()
	global c=runiform()
	global d=runiform()
	global e=runiform()
	synth_bootstrap 
	save weight_synth`i', replace
	}

* Open 4 new outreg files
use temp2_for_synth, clear
global controls "efile telefile statefed u rminwage maxbenefit welfarereform afdcwaiver statetax male age agesq black hispanic othrace male_black male_hispanic male_othrace ed_hsgrad ed_somecoll ed_college s_* child_year_* children_*"
xi: areg lwage generosity $controls [w=wgt] if ed_hsdropout==1, robust cluster(state) a(state) 
outreg using table-bootstrap-1.doc, noparen noaster se nocons replace ct("DROP") bdec(3)
outreg using table-bootstrap-2.doc, noparen noaster se nocons replace ct("DROP") bdec(3)
outreg using table-bootstrap-3.doc, noparen noaster se nocons replace ct("DROP") bdec(3)
outreg using table-bootstrap-4.doc, noparen noaster se nocons replace ct("DROP") bdec(3)

program define synth_regressions
	drop _merge
	sum wgt if weight_synth==.
	replace wgt=wgt/r(mean) if weight_synth==.
	replace wgt=wgt*weight_synth if weight_synth~=.
	sum wgt if weight_synth~=.
	replace wgt=wgt/r(mean) if weight_synth~=.
	global controls "efile telefile statefed u rminwage maxbenefit welfarereform afdcwaiver statetax male age agesq black hispanic othrace male_black male_hispanic male_othrace ed_hsgrad ed_somecoll ed_college s_* child_year_* children_*"
	xi: areg lwage generosity $controls [w=wgt] if adult==1, robust cluster(state) a(state) 
	outreg using table-bootstrap-1.doc, noparen noaster se nocons append ct("adult") bdec(3)
	xi: areg lwage generosity $controls [w=wgt] if ed_hsdropout==1, robust cluster(state) a(state) 
	outreg using table-bootstrap-2.doc, noparen noaster se nocons append ct("ed_hsdropout") bdec(3)
	xi: areg lwage generosity $controls [w=wgt] if ed_hsgrad==1, robust cluster(state) a(state) 
	outreg using table-bootstrap-3.doc, noparen noaster se nocons append ct("ed_hsgrad") bdec(3)
	xi: areg lwage generosity $controls [w=wgt] if ed_college==1, robust cluster(state) a(state) 
	outreg using table-bootstrap-4.doc, noparen noaster se nocons append ct("ed_college") bdec(3)
end

forvalues i = 1(1)100 {
	use temp2_for_synth, clear
	sort stfips
	merge stfips using weight_synth`i'
	synth_regressions
	}


*****************************
* 48 age/sex/educ groups
*****************************
clear
set more off
set matsize 800
set mem 1200m
cd "K:\EITC\"
use morgD2 if year>=1984 & year<=2002, clear
gen agetemp=age
recode agetemp min/29=1 30/34=2 35/39=3 40/44=4 45/49=5 50/max=6 *=.
gen edutemp=edu
recode edutemp min/11=1 12=2 13/15=3 16/max=4 
gen sextemp=male
recode sextemp 1=1 0=2
gen ind_occ=(agetemp*100)+(sextemp*10)+edutemp
*drop agetemp sextemp edutemp
sort year ind_occ
merge year ind_occ using dem48_cps.dta, nokeep
drop _merge
la var eitcyes_average "Fraction who get the EITC"
keep if adult==1 & children~=. & eitcyes~=.

* Instrument values for:
* 25-29 year old female high school dropouts 
tabstat eitcyes_average if agetemp==1 & male==0 & edutemp==1,by(year)
* 45-49 year old male college graduates 
tabstat eitcyes_average if agetemp==5 & male==1 & edutemp==4,by(year)

* Creating an 'actual federal EITC' variable
gen faminc_real=.
for Y in num 1984/2002 \ A in num 0.578 0.598 0.609 0.631 0.658 0.689 0.727 0.757 0.780 0.803 0.824 0.847 0.872 0.892 0.906 0.926 0.957 0.984 1.000: replace faminc_real=faminc/A if year==Y
gen eitc_exact_amount=eitc_exact_a*faminc_real if children==0
replace eitc_exact_amount=eitc_exact_a*faminc_real if children==1
replace eitc_exact_amount=eitc_exact_a*faminc_real if children>=2 & children~=.
recode eitc_exact_amount min/-1=.

gen eitcyes_actual=eitc_exact_amount
recode eitcyes_actual 0=0 .=. *=1

* Robustness check - dropping all obs with family income missing (asterisk out for main specification)
*drop if eitc_exact_amount==.

* Aggregated up to the labor market * year level
gen lhours=ln(uhourse)
collapse agetemp sextemp edutemp eitcyes_actual eitc_exact_amount amount_average employed lhours lwage eitcyes=eitcyes_average [aw=wgt], by(year ind_occ)
for any amount_average eitc_exact_amount: replace X=ln(X)

for any employed : xi: areg X eitcyes i.year,a(ind_occ) r cl(ind_occ) \ outreg using table-dem48-average.doc, coefastr bracket se nocons 3aster replace bdec(3) ct("X")
for any lhours lwage: xi: areg X eitcyes i.year,a(ind_occ) r cl(ind_occ) \ outreg using table-dem48-average.doc, coefastr bracket se nocons 3aster append bdec(3) ct("X")

* Summary statistics
sum employed lhours lwage eitcyes eitcyes_actual if e(sample)

* IV
log using iv_federal_specification, replace
for any employed lhours lwage: xi: ivreg2 X (eitcyes_actual=eitcyes) i.year i.ind_occ, r cl(ind_occ) first \ outreg using table-dem48-average.doc, coefastr bracket se nocons 3aster append bdec(3) ct("X-IV")
log close

* Alternative approach - using EITC amounts (for response to referees only)
for any employed lhours lwage: xi: areg X amount_average i.year,a(ind_occ) r cl(ind_occ) \ outreg using table-dem48-average.doc, coefastr bracket se nocons 3aster append bdec(3) ct("X")
for any employed lhours lwage: xi: ivreg2 X (eitc_exact_amount=amount_average) i.year i.ind_occ, r cl(ind_occ) first \ outreg using table-dem48-average.doc, coefastr bracket se nocons 3aster append bdec(3) ct("X-IV")

* Graph
for any lwage eitcyes: bysort ind_occ: egen temp1=mean(X) if year==1984 | year==1985 \ bysort ind_occ: egen temp2=max(temp1) \ bysort ind_occ: egen temp3=mean(X) if year==2001 | year==2002 \ gen dX=temp3-temp2 if year==2002 \ drop temp*
set scheme s1mono
*for any lwage: tw scatter dX deitcyes || lfit dX deitcyes, saving(dem, replace) legend(off) xti("Simulated change in share EITC eligible") yti("Change in log real hourly wages") ti("Gender-age-education cells")
for any lwage: tw scatter dX deitcyes || lfit dX deitcyes, legend(off) xti("Simulated change in share EITC eligible") yti("Change in log real hourly wages") ti("Figure 7: Changes in the Federal EITC" "Across Gender-Age-Education Cells") note("Note: Sample is all workers in all states. Change is from 1984/85 to 2001/02.")

* Aggregating age groups to three 10-year bands (25-34, 35-44, 45-55)
recode agetemp 1/2=1 3/4=3 5/6=5 *=.
gen ind_occ2=(agetemp*100)+(sextemp*10)+edutemp
collapse agetemp sextemp edutemp eitcyes_actual eitc_exact_amount amount_average employed lhours lwage eitcyes, by(year ind_occ2)
for any employed lhours lwage: xi: areg X eitcyes i.year,a(ind_occ) r cl(ind_occ) \ outreg using table-dem48-average.doc, coefastr bracket se nocons 3aster append bdec(3) ct("X - 10yr age bands")

* Also aggregating education to 2 groups (up to 12, more than 12)
recode edutemp 1/2=1 3/4=3 
gen ind_occ3=(agetemp*100)+(sextemp*10)+edutemp
collapse agetemp sextemp edutemp eitcyes_actual eitc_exact_amount amount_average employed lhours lwage eitcyes, by(year ind_occ3)
for any employed lhours lwage: xi: areg X eitcyes i.year,a(ind_occ) r cl(ind_occ) \ outreg using table-dem48-average.doc, coefastr bracket se nocons 3aster append bdec(3) ct("X - 10yr age bands & 2 ed groups")

* Coming up with a list of FIPS codes for states that ever had an EITC
cd "C:\Users\Andrew\EITC\"
use "State EITC rates.dta", clear
drop if year>2002 
egen tag=tag(stcode)
keep if tag
keep stcode
gen eitc_ever=1
sort stcode
merge stcode using xwalk_2letter_stfips
recode eitc_ever .=0 
drop _merge
sort eitc_ever stfips
drop if stcode=="IN"